package com.example.ndkjnidemo.home.dynamicregist;

import android.content.Context;
import android.util.Log;

import com.example.ndkjnidemo.home.staticregist.ExternClass;

/**
 * 动态注册
 */
public class JNIMethodDynamic {

    public String name;
    public Context testContext;
    private final String TAG = "NDK_JNI";

    // JNI Config 3 加载的jni库，库名：libndk-jni.so ,加载的时候省略lib和.so
    static {
        System.loadLibrary("ndk-jni");
    }

    public JNIMethodDynamic() {
        native_init();
    }

    public JNIMethodDynamic(Context context) {
        Log.d(TAG, "初始化");
        testContext = context;
        native_init();
    }

    public void setName(String name1) {
        Log.i(TAG, "setName:" + name1);
        name = name1;
    }

    public String getName() {
        Log.i(TAG, "getName:" + name);
        return name;
    }

    public String transimFromJNI(String from, ExternClass inner) {
        Log.i(TAG, "from=" + from + ",ExternClass name=" + inner.className);
        String returnString = "Java have get information";
        return returnString;
    }

    //以下内地方法实现在native层，这里只是作为函数的调用接口。
    public native String stringFromJNI();

    public native void native_init();

    public native void transmitToJNI(String from, ExternClass inner);

}
